#include "OptionsState.h"

#include "../items/StringInputBox.h"
#include "../items/ChangeStateButton.h"
#include "TitleState.h"
#include "GameState.h"

OptionsState* OptionsState::theOptionsState = NULL;

OptionsState::OptionsState(Frame *aFrame) {
    this->theTitle = "Set Game Options";
	this->theFrame = aFrame;
}

OptionsState::~OptionsState() {
}

void OptionsState::populate() {
	StringInputBox *setSize = new StringInputBox('1', "Size: ", this->theFrame->getGame().getSize());
	StringInputBox *setTries = new StringInputBox('2', "Tries: ", this->theFrame->getGame().getTries());
	ChangeStateButton *toGame = new ChangeStateButton('3', "Start", GameState::getInstance(this->theFrame));
	ChangeStateButton *back = new ChangeStateButton('4', "Back", TitleState::getInstance(this->theFrame));
	this->theItems.push_back(setSize);
	this->theItems.push_back(setTries);
	this->theItems.push_back(toGame);
	this->theItems.push_back(back);
}

OptionsState& OptionsState::getInstance(Frame *aFrame) {
	if(OptionsState::theOptionsState == NULL) {
		OptionsState::theOptionsState = new OptionsState(aFrame);
		OptionsState::theOptionsState->populate();
		aFrame->insertState(OptionsState::theOptionsState);
	}
    return *OptionsState::theOptionsState;
}
